const path=require('path')
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyWebpackPlugin=require('copy-webpack-plugin')
module.exports={
    mode:'production',
    entry:path.resolve(process.cwd(),'./src/index.js'),
    output:{
        path:path.resolve(process.cwd(),'./dist'),
        filename:"[name].js",
        publicPath:"/"
    },

    resolve: {
        alias: {
            // @ 符号  等同于 path.resolve(process.cwd(), "src/views")
            "@": path.resolve(process.cwd(), "src/views")
        }
    },
    module: {
        rules: [{
            test: /\.html$/i,
            loader: "html-loader",
        },
        {
            test: /\.ejs$/,
             loader: 'ejs-loader',
             options: {
                 variable: 'data', // 可以在模块当中使用data进行数据处理
             }
         }]
        },
    plugins: [
        new HtmlWebpackPlugin({
             title: "admin",
             filename: "index.html",
             template: "./public/index.html"
       }
  
       
       
       ) ,
       new CopyWebpackPlugin({
        patterns: [{
            from: "public",
            to: "./",
            globOptions: {
                ignore: ["**/index.html"] // 排除index.html
            }
        },
        {
            from:"./src/static",
            to:"./" 
         }
    
    ]
})
     ]
}